﻿using System;
using System.Data.SqlClient;

namespace Fingerbrisk.DataSource.FluentDatasourceInteract.SqlServer
{
    public class SqlQueryExpression : IQueryExpression
    {
        private readonly ITransaction _sqlTransaction;

        internal SqlQueryExpression(ITransaction sqlTransaction)
        {
            _sqlTransaction = sqlTransaction;
        }

        #region IQueryExpression Members

        public ITransaction Transaction { get { return _sqlTransaction; } }

        public IQueryExpression Select(string selectClause)
        {
            return this;
        }

        public IQueryExpression Select(string selectClause, int startIdx)
        {
            return this;
        }

        public IQueryExpression Select(string selectClause, int startIdx, int endIdx)
        {
            return this;
        }

        public IQueryExpression From(string dataObject)
        {
            return this;
        }

        public IQueryExpression Insert(string insertClause)
        {
            return this;
        }

        public IQueryExpression And(string andClause)
        {
            return this;
        }

        public IQueryExpression Where(string whereClause)
        {
            return this;
        }

        public IQueryExpression OrderBy(string orderClause)
        {
            return this;
        }

        public IQueryExpression GroupBy(string orderClause)
        {
            return this;
        }

        public IQueryExpression As(string alias)
        {
            return this;
        }

        public T ExecuteAs<T>(params QueryArg[] args)
        {
            String commandText = "";
            SqlCommand sqlCommand = new SqlCommand(commandText,((SqlSource)Transaction.Source).Connection);

            sqlCommand.ExecuteNonQuery();

            return default(T);
        }

        public System.Data.DataSet Execute(params QueryArg[] args)
        {
            /*String commandText = "";
            SqlCommand sqlCommand = new SqlCommand(commandText, ((SqlSource)Transaction.Source).Connection);

            sqlCommand.ExecuteNonQuery();*/

            return null;
        }

        #endregion
    }
}